import java.util.*;

public class Player
{
    private int strength = 100;
    private static Map<String, Thing> bag = new HashMap<>();
    
    public void step() {
        strength -= 20;
    }

    public void pick(Thing thing) {
        bag.put(thing.getName(), thing);
        System.out.println("获得了："+"["+thing.getName()+"]");
    }
    public void eat(String name) {
        Thing thing = bag.get(name);
        if(thing != null) {
            int strengthago=strength;
            strength += thing.getEnergy();
            bag.keySet().removeIf(key -> key.contains(name));
            if(strength >100) {
                strength = 100;
            }
            System.out.println("使用了："+name+"  "+"回复："+(strength-strengthago)+"生命值");
        }
    }
    public void checkBag() {
        bag.keySet().stream().forEach(key -> System.out.print(key + " "));
        System.out.println(); 
    }
    public boolean isDead() {
        System.out.println("你已死亡，任务失败！");
        return strength <= 0;
    }
    
}
